package org.fmblzf.library.asyc;

import android.content.Context;

import org.fmblzf.library.inter.AsmHandleListener;
import org.fmblzf.library.inter.InterListener;

/**
 * Created by Administrator on 2016/1/20.
 */
public class AsycOperate {

    /**
     * 该类的标记
     */
    private static final String TAG = AsycOperate.class.getName();

    /**
     * 上下文
     */
    private Context mContext;

    /**
     * 静态实体类
     */
    private static AsycOperate instance;

    /**
     * 单例模式
     * @param context
     */
    private AsycOperate(Context context){
        this.mContext = context;
    }

    /**
     * 外部公共方法，实现单例
     * @param context
     * @return
     */
    public  static synchronized  AsycOperate  getInstance(Context context){
        if (instance == null){
            instance = new AsycOperate(context);
        }
        return instance;
    }

    /**
     * 开始异步操作
     * @param asmHandleListener 回调处理类
     * @param interListener 异步的具体操作类
     */
    public void startAsyOperate(AsmHandleListener asmHandleListener,InterListener interListener){
        AsycHandler handler = new AsycHandler(asmHandleListener);
        AsycThread thread = new AsycThread(handler,interListener);
        new Thread(thread).start();
    }

}
